#pragma once
#include <iostream>
#include <pthread.h>
#include <unistd.h>
#include <string>
#include <cstdlib>
#include <errno.h>
#include <cstring>
#include <stdio.h>
#include <vector>
#include <stdlib.h>


class Mutex
{
public:
    Mutex(pthread_mutex_t* lock) :_lock(lock)
    {}
    void Link()
    {
        pthread_mutex_lock(_lock);
    }

    void unlink()
    {
        pthread_mutex_unlock(_lock);
    }

    pthread_mutex_t* _lock;
};

class LockMutex
{
public:
    LockMutex(pthread_mutex_t* lock)
    :_mutex(lock)
    {
        _mutex.Link();
    }
    ~LockMutex()
    {
        _mutex.unlink();
    }
    Mutex _mutex;
};
